stack = []

#简单堆栈操作
def pop():
    return stack.pop()

def push(x):
    stack.append(x)

def isNum(x):
    try:
        float(x)
        return True
    except:
        return False

if __name__ == "__main__":
    opList = input("输入逆波兰式").split(' ')
    errorOP = False
    for i in range(len(opList)):
        op = opList[i]
        if isNum(op):
            push(float(op))
        elif op == '+':
            push(pop() + pop())
        elif op == '-':
            op2 = pop()
            op1 = pop()
            push(op1 - op2)
        elif op == '*':
            push(pop() * pop())
        elif op == '/':
            op2 = pop()
            op1 = pop()
            push(op1 / op2)
        else:
            print('未知操作符:', op)
            errorOP = True
            break

    if length := len(stack) > 1 or len(stack) == 0 or errorOP:
        print("算式输入错误")
    else:
        num = pop()
        print('%g' %num)

